# 用requests框架 主要针对 post 方式 , 获取json数据

import requests

url = "https://fanyi.baidu.com/sug"

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36"
}

data = {
    "kw": "你好"
}

resp = requests.post(url, data=data, headers=headers)
resp.encoding = 'utf-8'

json = resp.json()
# print(resp.status_code)

print(json)

# 记得关闭
resp.close()